home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8779 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: hacgate2.hac.com!redwood!ddavenpo
  2. From: ddavenpo@redwood.hac.com (Darren C Davenport)
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Re: on OO differnces between Ada95 and C++
  5. Followup-To: comp.lang.ada,comp.lang.c++
  6. Date: 26 Feb 1996 17:08:39 GMT
  7. Organization: Hughes Aircraft Company
  8. Message-ID: <4gspen$ot0@hacgate2.hac.com>
  9. References: <4gbq7q$g08@qualcomm.com> <3129F185.41C6@Rational.COM> <4gi413$qo1@druid.borland.com>
  10. NNTP-Posting-Host: redwood.dn.hac.com
  11.  
  12. Pete Becker (pete@borland.com) wrote:
  13. : In article <3129F185.41C6@Rational.COM>, jDesquilbet@Rational.COM says...
  14. : >
  15. : >- you may have several different definitions for the same class in the
  16. : >same program, as long as they are never compiled together in the same
  17. : >compilation unit; example:
  18. : >
  19. : >#define private public // *** BERK! ***
  20. : >#include "...h"        // second definition for the same class
  21. : >#undef private
  22.  
  23. : This is not true. A program that attempts to do this violates the one 
  24. : definition rule, so it is not a legal C++ program.
  25. :     -- Pete
  26.  
  27. We need to be careful here with terms used to describe C++ constructs.  
  28. A class name declaration is a C++ declaration (ARM C++ 3.1) not a definition.
  29. This is what is specified in ".h" files.  There can be multiple declarations
  30. so the above code is legal C++ code.  There can only be one definition
  31. of each object, function, class, and enumerator in a program and these
  32. are specified in ".cc" files.  Mr. Becker is correct about stating that
  33. there must be only one definition but that rule does not apply in this
  34. instance.
  35.  
  36. Darren Davenport
  37.  
  38.